<?php
//Create images and css for lang
    $height=3776;
    $width=16;
    $str='';
    $im = imagecreatetruecolor($width, $height);
    imagealphablending($im, false);
    $col=imagecolorallocatealpha($im,255,255,255,127);
    imagefilledrectangle($im,0,0,$width, $height,$col);
    imagealphablending($im,true);
    $dir='/Project/law_and_partners/themes/kcms_edit/images/flags';
    $files = glob($dir.'/*.{png}', GLOB_BRACE);
    foreach($files as $i=>$file) {
        $image = imagecreatefrompng($file);
        imagecopy($im,$image,0,$i*$width,0,0,16,16);
        imagedestroy($image);
        //css
        $file_name_full=end(explode("/", $file));
        $file_name=explode(".", $file_name_full);
        $file_name=$file_name[0];
        $y=-($i*16);
        $str.="#_lang_$file_name
        {
        background: transparent url(../images/flags.png)  0 ".$y."px no-repeat;
        }
        "; 
    }
    imagealphablending($im, false);
    imagesavealpha($im, true);
    imagepng($im,'aa.png',9);

    imagedestroy($im);
    echo $str;
?>
